<?php
/**
 * Created by PhpStorm.
 * User: Victor
 * Date: 2018/11/15
 * Time: 14:51
 */
$id = isset($_GET['id']) ? $_GET['id'] : '2';
if($id == 0){
    $arr = ['code' => 300, 'msg' => '无此数据'];
    echo json_encode($arr);
}
//连接数据库
$db = new mysqli('localhost', 'root', 'root', 'tt');
//连接数据库判断
if ($db->connect_error) {
    $arr = ['code' => 0, 'msg' => '数据库连接失败'];
    echo json_encode($arr);
}
$sql = "SELECT * FROM churu_jiekou where id = '".$id."'";
$result = $db->query($sql);
var_dump($result->fetch_assoc());die();
if ($result->num_rows ==1) {
    // 输出数据
    $row = $result->fetch_assoc();
    if($row['bz']==1){
        $arr = ['code' => 1, 'msg' => '成功'];
        echo json_encode($arr);
    }else{
        $arr = ['code' => 300, 'msg' => '支付中'];
        echo json_encode($arr);
    }
//    while($row = $result->fetch_assoc()) {
//        echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
//    }
}else{
    $arr = ['code' => 0, 'msg' => 'error:数据重复'];
    echo json_encode($arr);
}
$db->close();

